﻿using System;
using System.ComponentModel.DataAnnotations.Schema;
using JetBrains.Annotations;
using Volo.Abp.Domain.Entities;

namespace CommonManagement
{
    /// <summary>
    /// 余额变动记录类
    /// </summary>
    public class Balance: Entity<int>
    {
        /// <summary>用户Id</summary>
        public int UserId { get; protected set; }

        /// <summary>应用类别</summary>
        public string AppType { get; protected set; }

        /// <summary>变更类型</summary>
        public string ChangeType { get; protected set; }

        /// <summary>变更事件</summary>
        public string Event { get; protected set; }

        /// <summary>变更金额</summary>
        public decimal ChangeAmount { get; protected set; }

        /// <summary>变更日期</summary>
        public DateTime ChangeTime { get; protected set; }

        /// <summary>用户</summary>
        [ForeignKey("UserId")]
        public User User { get; protected set; }

        private Balance() { }

        internal Balance(
            int userId,
            string appType,
            [NotNull] string changeType,
            [NotNull] string @event,
            decimal changeAmount)
        {
            UserId = userId;
            AppType = appType;
            ChangeType = changeType;
            Event = @event;
            ChangeAmount = changeAmount;
            ChangeTime = DateTime.Now;
        }
    }
}